package com.dl.DaoImpl;

import com.dl.Bean.Customer;
import com.dl.Dao.ZhuceYanZheng;
import com.dl.util.DBConnection;

import java.sql.*;

public class CustomerYanzheng implements ZhuceYanZheng {
    private Connection conn = null ;
    private Statement st = null ;
    private ResultSet rs=null;
    @Override
    public boolean YanZheng(Customer cs) throws SQLException {
        DBConnection db=new DBConnection();
        conn=db.getConnection();
        st=conn.createStatement();
        String sql="select * from customer";
        rs=st.executeQuery(sql);
        System.out.println("注册验证中");
        while(rs.next()){
            String name=rs.getString("name");
            String password=rs.getString("password");
            String idcard=rs.getString("idcard");
            if(name.equals(cs.getName())==false&&password.equals(cs.getPassword())==false&&idcard.equals(cs.getIdcard())==false){
                System.out.println("注册验证成功");
                db.AllClose();
                return true;
            }
        }
        db.AllClose();
        System.out.println("注册验证失败");
        return false;
    }
}
